package service.api.ai;


import java.io.IOException;
import java.nio.file.Paths;

public class PyTorchResNet {
//    public static void main(String[] args) throws IOException, TranslateException, MalformedModelException, ModelNotFoundException {
//        DownloadUtils.download("https://djl-ai.s3.amazonaws.com/mlrepo/model/cv/image_classification/ai/djl/pytorch/resnet/0.0.1/traced_resnet18.pt.gz", "build/pytorch_models/resnet18/resnet18.pt", new ProgressBar());
//        DownloadUtils.download("https://djl-ai.s3.amazonaws.com/mlrepo/model/cv/image_classification/ai/djl/pytorch/synset.txt", "build/pytorch_models/resnet18/synset.txt", new ProgressBar());
//
//        Translator<Image, Classifications> translator = ImageClassificationTranslator.builder()
//                .addTransform(new Resize(256))
//                .addTransform(new CenterCrop(224, 224))
//                .addTransform(new ToTensor())
//                .addTransform(new Normalize(
//                        new float[] {0.485f, 0.456f, 0.406f},
//                        new float[] {0.229f, 0.224f, 0.225f}))
//                .optApplySoftmax(true)
//                .build();
//
//        Criteria<Image, Classifications> criteria = Criteria.builder()
//                .setTypes(Image.class, Classifications.class)
//                .optModelPath(Paths.get("build/pytorch_models/resnet18/resnet18.pt"))
//                .optTranslator(translator)
//                .optProgress(new ProgressBar()).build();
//
//        ZooModel<Image, Classifications> model = criteria.loadModel();
//        Image img = ImageFactory.getInstance().fromUrl("https://img-blog.csdnimg.cn/4c1c40b41c6a49afa69f7ccf96e24ddf.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA57yW56iL5ZyI5a2Q,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center");
//        img.getWrappedImage();
//        Predictor<Image, Classifications> predictor = model.newPredictor();
//        Classifications classifications = predictor.predict(img);
//        System.out.println(classifications);
//    }

}
